<template>
  <div>
    <div class="header">
      <img
        src="../../assets/images/fanhui.png"
        height="23"
        alt=""
        @click="back"
      />
      <div>新增</div>
      <img src="../../assets/images/首页按钮.png" height="23" alt="" />
    </div>
    <van-form>
      <van-field
        v-model="custName"
        label="客户姓名"
      />
      <van-field
        v-model="telephone"
        label="联系方式"
       
      />
      <div style="margin-top: 16px">
        <van-field
          v-model="education"
          label="学历"
         
        />
        <van-field v-model="age" label="年龄" />
        <van-field v-model="sex" label="性别" />
        <van-field
          v-model="cityName"
          label="所属城市"
        />
        <van-field
          v-model="company"
          label="公司名称"
        />
        <van-field
          v-model="position"
          label="职位"
        />
      </div>

      <div style="margin: 16px">
        <van-button round block type="info" @click="btn">保存</van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
import { custXZ } from "../../request/api";
export default {
  data() {
    return {
      //名字
      custName: "",
      //电话
      telephone: "",
      //学历
      education: "",
      //年龄
      age: '',
      //性别
      sex: "",
      //所属城市
      cityName: "",
      //公司名称
      company: "",
      //职位
      position: "",
      data: [],
    };
  },
  methods: {
    back() {
      this.$router.back();
    },
    btn() {
    //   let custName = this.custName;
    //   let cityName = this.cityName;
    //   let company = this.company;
    //   let position = this.position;
    //   let telephone = this.telephone;
    //   let education = this.education;
    //   let sex = this.sex;
    //   let age = Number(this.age);
      console.log(
        typeof custName,
        typeof cityName,
        typeof company,
        typeof position,
        typeof telephone,
        typeof education,
        typeof sex,
        typeof age,
      );

      custXZ({
        custName: this.custName,
        cityName: this.cityName,
        company: this.company,
        position: this.position,
        telephone: this.telephone,
        education: this.education,
        sex: this.sex,
        age: Number(this.age),
      }).then((res) => {
        if (res.errCode == 0) {
          console.log(res);
          this.$router.back()
        }
      });
    },
  },
};
</script>
 
<style lang = "less" scoped>
.header {
  width: 100vw;
  height: 64px;
  background: #003399;
  display: flex;
  color: #fff;
  font-size: 22px;
  padding: 25px 10px;
  box-sizing: border-box;
  justify-content: space-between;
  img {
    margin-top: 3px;
  }
}
</style>